// 网络请求封装
const wxRequest = (params, url) => {
	wx.showToast({
		title: '加载中',
		icon: 'loading'
	});
	wx.request({
		url: url,
		method: params.method || 'GET',
		data: params.data || {},
		header: {
			'Content-Type': params.headerType || 'application/json'
		},
		success: res => {
			params.success && params.success(res);
			wx.hideToast();
		},
		fail: res => {
			wx.showToast({
				title: '网络连接失败',
				icon: 'loading'
			});
			params.fail && params.fail(res);
		},
		complete: res => {
			params.complete && params.complete(res);
		}
	});
};


const newDate = new Date();

const getDate = () => newDate.getFullYear() + '/' + (newDate.getMonth() + 1) + '/' + newDate.getDate();

const getDay = () => " 星期" + "日一二三四五六".charAt(new Date().getDay());

const getTheday = () => getDate() + getDay()
const getWeek = () => {
	var now = new Date();
	var date2 = new Date(2020, 7, 31); //开学时间
	// 1000毫秒 * 60秒 * 60分钟* 24小时 = 86400000
	var day = Math.round((now.valueOf() - date2.valueOf()) / 86400000);
	let week = Math.ceil((day + (date2.getDay() + 1 - 1)) / 7);
	let currday = now.getDay() == 0 ? 7 : now.getDay()
	return {
		week,
		currday
	}
}
module.exports = {
	getTheday,
	getWeek
};